How to write blockchain components?
Source
At the time of adding this tutorial, our repositories contain components that uses antelope
tools and MongoDB databases. If your History Tools project requires it, all you have to do is import Starter-Kit or in the case of API, use @alien-worlds/aw-antelope
and @alien-worlds/aw-storage-mongodb directly. In both cases, you also need a package of specific contracts, which contain all necessary components (repository, services, etc.). Here, too, we have a range of ready-made packages based on contracts related to our products. If you still need to create your own components because you couldn't find ones that meet your requirements, remember not to directly mix them with any of the existing packages. For instance, don't fork aw-core
and add specific modifications if your implementation could also be useful to others.
Depending on which Blockchain component you want to modify, create a new repository based on the existing one. Check how the original is implemented and do the same in your package. Almost every open-source project package is based on interfaces contained in aw-core
. Therefore, as much as possible, do not modify your interfaces and use what already exists. This will allow everyone to easily use your work along with other packages that are already available in our repositories. If there is no other option, you can always consider extending or modifying existing interfaces. Just remember that you need to provide a strong rationale, because changing a widely used and accessible package for the purposes of one may not be met with enthusiasm (without concrete grounds).
-
If you need to implement your version of a serializer, abis service, smart contracts, or the blockchain itself, check the available implementation of @alien-worlds/aw-antelope, which contains the basic implementation used by default in our history tools and APIs. In the case of history tools, if you are changing eos, you will also have to create a new
kit
(similar to the Starter Kit). This is necessary to maintain the same implementation scheme of history tools, regardless of the used dependencies. The user of your package should only have to import yourkit
and be able to work, enjoying your work. -
If you want to implement basic components for some new contract which is not yet implemented (or won't be), you have two options. The first option is to write everything from scratch based on one of the available packages (e.g. dao.worlds) or use our CLI AlienGen. Just enter the ABI of your contract and the generator will create all the necessary components.